/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Persistencia;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author JAVA
 */
public class Conexion {
    
    private static String driver="com.mysql.jdbc.Driver";
    private static String conexion="jdbc:mysql://192.168.1.17/redskate";
    private static String usuario="cibernos";
    private static String password="cibernos";
    private Connection con;
    private Statement st;
    
    public static String getDriver(){
        return driver;
    }
    
    public static String getConexion(){
        return conexion;
    }
    
    public static String getUsuario(){
        return usuario;
    }
    
    public static String getPassword(){
        return password;
    }
    
    public Conexion(){
        con=null;
        st=null;
        try{
            Class.forName(driver).newInstance();
            con = (Connection) DriverManager.getConnection(conexion, usuario, password);
            st = (Statement) con.createStatement();
        }catch (SQLException ex) {
            Logger.getLogger(PersistenciaTabla.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(PersistenciaTabla.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(PersistenciaTabla.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(PersistenciaTabla.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public Statement open(){
        return st;
    }
    
    public void close(){
        try{
            con.close();
            st.close();
        }catch (SQLException ex) {
            Logger.getLogger(PersistenciaTabla.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
